package com.baige.api.app.controller;

import com.baige.api.app.sdk.request.UserAccountFlowRequest;
import com.baige.api.app.sdk.response.UserAccountCashOutResponse;
import com.baige.api.app.sdk.response.UserAccountFlowResponse;
import com.baige.api.app.sdk.response.UserAccountResponse;
import com.baige.common.core.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.hibernate.validator.constraints.NotEmpty;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * 用户账户接口
 * @author wulg
 * @date 2018/12/13.
 */
@Api(value = "UserAccountController", description = "用户账户接口", produces = org.springframework.http.MediaType.APPLICATION_JSON_VALUE)
@RestController
@RequestMapping("/api/rest/user/account")
public class UserAccountController
{
    private static final Logger logger = LoggerFactory.getLogger(UserAccountController.class);

    /**
     * 用户申请提现
     * @param userId 用户id
     * @return Result<MsgResponse>
     */
    @PostMapping(value = "/v1/cashOut/{userId}", produces = {"application/json;charset=UTF-8", "application/xml;charset=UTF-8"})
    @ApiOperation(value = "用户申请提现", notes = "用户申请提现", httpMethod = "POST", produces = org.springframework.http.MediaType.APPLICATION_JSON_VALUE)
    public Result<MsgResponse> userAccountCashOut(@PathVariable("userId") String userId)
    {
        return null;
    }

    /**
     * 获取用户账户流水
     * @param userId 用户id
     * @param requestParams 请求参数
     * @param bindingResult 参数校验
     * @return Result<List<UserAccountFlowResponse>>
     */
    @GetMapping(value = "/v1/flow/{userId}", produces = {"application/json;charset=UTF-8", "application/xml;charset=UTF-8"})
    @ApiOperation(value = "获取用户账户流水", notes = "获取用户账户流水", httpMethod = "GET", produces = org.springframework.http.MediaType.APPLICATION_JSON_VALUE)
    public Result<List<UserAccountFlowResponse>> getUserAccountFlowList(@PathVariable("userId") String userId, @Valid @ModelAttribute("request") UserAccountFlowRequest requestParams, BindingResult bindingResult)
    {
        if (bindingResult.hasErrors()) {
            logger.error("获取用户账户流水参数传递错误,message:{}", bindingResult.getFieldErrors().get(0).getDefaultMessage());
            return BaseResponse.newErrorParamReturnObject(bindingResult.getFieldErrors().get(0).getDefaultMessage());
        }
        return null;
    }

    /**
     * 获取用户账户信息
     * @param userId 用户id
     * @return Result<AccountResponse>
     */
    @GetMapping(value = "/v1/{userId}", produces = {"application/json;charset=UTF-8", "application/xml;charset=UTF-8"})
    @ApiOperation(value = "获取用户账户信息", notes = "获取用户账户信息", httpMethod = "GET", produces = org.springframework.http.MediaType.APPLICATION_JSON_VALUE)
    public Result<UserAccountResponse> getUserAccountInfo(@PathVariable("userId") String userId) {
        return null;
    }


    /**
     * 获取用户账户提现像详细信息
     * @param cashOutId 提现申请id
     * @return Result<UserAccountCashOutResponse>
     */
    @GetMapping(value = "/v1/cashOut/{cashOutId}", produces = {"application/json;charset=UTF-8", "application/xml;charset=UTF-8"})
    @ApiOperation(value = "获取用户账户提现信息", notes = "获取用户账户提现信息", httpMethod = "GET", produces = org.springframework.http.MediaType.APPLICATION_JSON_VALUE)
    public Result<UserAccountCashOutResponse> getAccountCashOutInfo(@PathVariable("cashOutId") String cashOutId) {
        return null;
    }

}
